/*
 * Copyright (c) 2014 pkzd/1.0, 颜文泽(robin)
 * All rights reserved.
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 *     1 Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     2 Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#include	<param.h>

.globl fork
fork:
	movl	$(FORK), %eax
	int	$(SYSCALL)
	ret
.globl execve
execve:
	movl	4(%esp), %ebx
	movl	8(%esp), %ecx
	movl	12(%esp), %edx
	movl	$(EXECVE), %eax
	int	$(SYSCALL)
	ret
.globl exit
exit:
	movl	4(%esp), %ebx
	movl	$(EXIT), %eax
	int	$(SYSCALL)
	ret
.globl wait
wait:
	movl	4(%esp), %ebx
	movl	$(WAIT), %eax
	int	$(SYSCALL)
	ret
.globl getpid
getpid:	
	movl	$(GETPID), %eax
	int	$(SYSCALL)
	ret
.globl getppid
getppid:	
	movl	$(GETPPID), %eax
	int	$(SYSCALL)
	ret
.globl getuid
getuid:	
	movl	$(GETUID), %eax
	int	$(SYSCALL)
	ret
.globl geteuid
geteuid:	
	movl	$(GETEUID), %eax
	int	$(SYSCALL)
	ret
.globl getgid
getgid:	
	movl	$(GETGID), %eax
	int	$(SYSCALL)
	ret
.globl getegid
getegid:	
	movl	$(GETEGID), %eax
	int	$(SYSCALL)
	ret
.globl setpgid
setpgid:	
	movl	$(SETPGID), %eax
	int	$(SYSCALL)
	ret
.globl creat
creat:
	movl    4(%esp), %ebx
        movl    8(%esp), %ecx
        movl    $(CREAT), %eax
        int     $(SYSCALL)
        ret
.globl open 
open:
        movl    4(%esp), %ebx
        movl    8(%esp), %ecx
	movl	12(%esp), %edx
        movl    $(OPEN), %eax
        int     $(SYSCALL)
        ret
.globl close 
close:
        movl    4(%esp), %ebx
        movl    $(CLOSE), %eax
        int     $(SYSCALL)
        ret
.globl dup 
dup:
        movl    4(%esp), %ebx
        movl    $(DUP), %eax
        int     $(SYSCALL)
        ret
.globl read 
read:
        movl    4(%esp), %ebx
        movl    8(%esp), %ecx
        movl    12(%esp), %edx
        movl    $(READ), %eax
        int     $(SYSCALL)
        ret
.globl write 
write:
        movl    4(%esp), %ebx
        movl    8(%esp), %ecx
        movl    12(%esp), %edx
        movl    $(WRITE), %eax
        int     $(SYSCALL)
        ret
.globl lseek 
lseek:
        movl    4(%esp), %ebx
        movl    8(%esp), %ecx
        movl    12(%esp), %edx
        movl    $(LSEEK), %eax
        int     $(SYSCALL)
        ret
.globl mknod 
mknod:
        movl    4(%esp), %ebx
        movl    8(%esp), %ecx
        movl    12(%esp), %edx
        movl    $(MKNOD), %eax
        int     $(SYSCALL)
        ret
.globl access 
access:
        movl    4(%esp), %ebx
        movl    8(%esp), %ecx
        movl    $(ACCESS), %eax
        int     $(SYSCALL)
        ret
.globl stat
stat:
	movl	4(%esp), %ebx
	movl	8(%esp), %ecx
	movl	$(STAT), %eax
	int	$(SYSCALL)
	ret
.globl fstat
fstat:
	movl	4(%esp), %ebx
	movl	8(%esp), %ecx
	movl	$(FSTAT), %eax
	int	$(SYSCALL)
	ret
.globl link 
link:
        movl    4(%esp), %ebx
        movl    8(%esp), %ecx
        movl    $(LINK), %eax
        int     $(SYSCALL)
        ret
.globl unlink
unlink:
        movl    4(%esp), %ebx
        movl    $(UNLINK), %eax
        int     $(SYSCALL)
        ret
.globl mkdir
mkdir:
        movl    4(%esp), %ebx
        movl    8(%esp), %ecx
        movl    $(MKDIR), %eax
        int     $(SYSCALL)
        ret
.globl rmdir
rmdir:
        movl    4(%esp), %ebx
        movl    $(RMDIR), %eax
        int     $(SYSCALL)
        ret
.globl chdir
chdir:
        movl    4(%esp), %ebx
        movl    $(CHDIR), %eax
        int     $(SYSCALL)
        ret
.globl time 
time:
        movl    4(%esp), %ebx
        movl    $(TIME), %eax
        int     $(SYSCALL)
        ret
.globl brk
brk:	movl	4(%esp), %ebx
	movl	$(BRK), %eax
	int	$(SYSCALL)
	ret
